package com.techstar.api.service;

import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;

/**
 * 
 * @author EinIce
 * @description roma-API网关认证信息配置，result接口配置
 * @date 2021年6月24日
 *
 */
public enum HttpClientHeper {
    instance;

    public RequestConfig requestConfig = RequestConfig.custom()
            .setConnectTimeout(30000).setConnectionRequestTimeout(30000)
            .setSocketTimeout(30000).build();
    public CloseableHttpClient httpclient = HttpClients.custom().build();

    public void buildHead(HttpRequestBase httpRequestBase,String time,String host,String secret) {
        httpRequestBase.addHeader("X-Sdk-Date", time);
        httpRequestBase.addHeader("host", host);
        httpRequestBase.addHeader("Authorization", secret);
        httpRequestBase.setConfig(requestConfig);
    }

    public void buildContextType(HttpRequestBase httpRequestBase) {
        httpRequestBase.addHeader("Content-Type", "application/json");
    }
}
